import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    //总价格
    sum:{
      sum1:0
    },
    //手机数量
    phone:{
      count:0,
      price:1000
    },
    //电脑数量
    computer:{
      count:0,
      price:2000
    },
    //键盘数量
    keyboard:{
      count:0,
      price:200
    }
  },
  getters: {
    total(state){
      return ((state.phone.price*state.phone.count)+(state.computer.price*state.computer.count)+(state.keyboard.price*state.keyboard.count))
    }
  },
  mutations: {
    count1(state){
      state.phone.count++;
    },
    count2(state){
      state.computer.count++;
    },
    count3(state){
      state.keyboard.count++;
    },
    count4(state){
      state.phone.count--;
    },
    count5(state){
      state.computer.count--;
    },
    count6(state){
      state.keyboard.count--;
    },
  },
  actions: {
  },
  modules: {
  }
})
